import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(Fullscreen());
}

class Fullscreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    SystemChrome.setEnabledSystemUIMode(
      SystemUiMode.edgeToEdge,
      overlays: [SystemUiOverlay.bottom], // 隐藏所有系统 UI
    );
    if (Theme.of(context).platform == TargetPlatform.android) {
      // android 平台
      SystemUiOverlayStyle _style = SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        systemStatusBarContrastEnforced: false,
        statusBarBrightness: Brightness.dark, // 设置状态栏图标为深色（iOS上这通常改变背景色）
      );
      SystemChrome.setSystemUIOverlayStyle(_style);
    }
    print(MediaQuery.of(context).padding);

    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark, //dark或light
      child: Material(
        child: Directionality(
          textDirection: TextDirection.ltr,
          child: Container(color: Colors.amber, child: _buildBanner()),
        ),
      ), //body
    );
  }

  Widget _buildBanner() => CarouselSlider(
    options: CarouselOptions(height: 400.0,
        viewportFraction:1,autoPlay: true,enableInfiniteScroll: false),
    items: [1, 2, 3, 4, 5].map((i) {
      return Builder(
        builder: (BuildContext context) {
          return Container(
            width: MediaQuery.of(context).size.width,
            margin: EdgeInsets.symmetric(horizontal: 10),
            padding: EdgeInsets.all(0),
            decoration: BoxDecoration(color: Colors.red),
            child: Container(
              color: Colors.pink,

              child:  Text('text $i', style: TextStyle(fontSize: 16.0)),
            )
          );
        },
      );
    }).toList(),
  );
}
